/*
 * @Author: zhangyang
 * @Date: 2021-08-26 16:34:59
 * @LastEditTime: 2022-03-14 11:22:36
 * @Description: 系统管理相关
 */
import { MockApi } from "../decorator/MockApi";
import Mock from 'mockjs';
import nodeInfo from "./nodeInfo";
import roleInfo from "./roleInfo";
import adminInfo from "./adminInfo";
export class SystemController {
  @MockApi('10000/5')
  static getNodeList(params: Record<string, any>) {
    const data = Mock.mock(nodeInfo);
    return { status: 0, data, msg: 'ok'};
  }

  @MockApi('10000/6') // 添加节点
  @MockApi('10000/7') // 编辑节点
  @MockApi('10000/9') // 添加 | 编辑角色
  @MockApi('10000/10') // 删除角色
  @MockApi('10000/14') // 添加 | 编辑管理员
  @MockApi('10000/15') // 删除管理员

  // 通用操作成功
  static common_success(params: Record<string, any>) {
    return { status: 0, data: {}, msg: 'ok'};
  }

  @MockApi('10000/8')
  static getRoleList(params: Record<string, any>) {
    const data = Mock.mock(roleInfo);
    return { status: 0, data, msg: 'ok'};
  }

  @MockApi('10000/12')
  static getAdminList(params: Record<string, any>) {
    const data = Mock.mock({
      list: adminInfo,
      total: adminInfo.length
    });
    return { status: 0, data, msg: 'ok'};
  }

  @MockApi('10000/13')
  static getEnabledRole(params: Record<string, any>) {
    const data = Mock.mock(roleInfo.filter((item) => item.is_enable));
    return { status: 0, data, msg: 'ok'};
  }
}
